package edu.bw;

import edu.bw.service.HelloService;
import edu.bw.service.InitAndDestroy;
import edu.bw.service.SetterInjection;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test01 {
    @Test
    public void test01(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        HelloService helloService = (HelloService) context.getBean("helloService");
        System.out.println(helloService);
    }
    @Test
    public void test02(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        HelloService helloService = context.getBean(HelloService.class);
        helloService.syaHello();
    }
    @Test
    public void test03(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        HelloService helloService = context.getBean("helloService", HelloService.class);
        helloService.syaHello();
    }
    @Test
    public void test04(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        SetterInjection setterInjection = context.getBean("setterInjection", SetterInjection.class);
        System.out.println(setterInjection);
    }
    @Test
    public void test05(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        InitAndDestroy initAndDestroy = context.getBean("initAndDestroy", InitAndDestroy.class);
        System.out.println(initAndDestroy);
        context.close();
    }
}
